import {lazy, Suspense} from 'react';
import {Route, Switch,Redirect} from "react-router-dom"
//导入loading组件
import Loading from '@/components/Loading'
//使用lazy导入需要的组件
const Login = lazy(() => import("@/views/login/Index.jsx"));
const dashboard = lazy(() => import("@/views/dashboard/Index.jsx"));

//编写路由规则
const Routes = () =>{
    return (
        <Suspense fallback={<Loading/>}>
            <Switch>
                 <Route path="/login" component={Login}></Route>
                 <Route path="/dashboard" component={dashboard}></Route>
                 <Redirect from="/" to="/login"></Redirect>
            </Switch>
        </Suspense>
    )
}
export default Routes 